package material.factory;

import java.util.ArrayList;
import java.util.List;

/**
 * 披萨的基类
 */
abstract public class Pizza {
    String name;//披萨的名称
    String dough;//披萨的所用的面料
    String sauce;//披萨所用的酱料
    List<String> toppings = new ArrayList<String>();//配料

    public String getName() {
        return name;
    }

    //准备披萨
    public void prepare() {
        System.out.println("Preparing " + name);
    }

    //烘烤披萨
    public void bake() {
        System.out.println("Baking " + name);
    }

    //裁剪披萨
    public void cut() {
        System.out.println("Cutting " + name);
    }

    //打包披萨
    public void box() {
        System.out.println("Boxing " + name);
    }

    public String toString() {
        // code to display pizza name and ingredients
        StringBuffer display = new StringBuffer();
        display.append("---- " + name + " ----\n");
        display.append(dough + "\n");
        display.append(sauce + "\n");
        for (String topping : toppings) {
            display.append(topping + "\n");
        }
        return display.toString();
    }
}
